package grobit.wire

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

class MockSocketFactory implements SocketFactory {
    String responseString

    Socket getConnectedSocket(InetSocketAddress socketAddress) {
        InputStream loadedInputStream = new ByteArrayInputStream(responseString.getBytes('ISO-8859-1'))
        Socket mockSocket = mock(Socket.class)
        OutputStream outputStream = mock(OutputStream.class)
        when(mockSocket.getOutputStream()).thenReturn(outputStream)
        when(mockSocket.getInputStream()).thenReturn(loadedInputStream)
        return mockSocket
    }
}
